/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author riccardo
 */
@Entity
@Table(name = "CITTA")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Citta.findAll", query = "SELECT c FROM Citta c"),
    @NamedQuery(name = "Citta.findByCap", query = "SELECT c FROM Citta c WHERE c.cap = :cap"),
    @NamedQuery(name = "Citta.findByNome", query = "SELECT c FROM Citta c WHERE c.nome = :nome"),
    @NamedQuery(name = "Citta.findByNazione", query = "SELECT c FROM Citta c WHERE c.nazione = :nazione")})
public class Citta implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "CAP")
    private Integer cap;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 255)
    @Column(name = "nome")
    private String nome;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "nazione")
    private String nazione;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "luogo")
    private Collection<Escursione> escursioneCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "arrivo")
    private Collection<Volo> voloCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "partenza")
    private Collection<Volo> voloCollection1;
    @OneToMany(mappedBy = "indirizzo")
    private Collection<Hotel> hotelCollection;

    public Citta() {
    }

    public Citta(Integer cap) {
        this.cap = cap;
    }

    public Citta(Integer cap, String nome, String nazione) {
        this.cap = cap;
        this.nome = nome;
        this.nazione = nazione;
    }

    public Integer getCap() {
        return cap;
    }

    public void setCap(Integer cap) {
        this.cap = cap;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    public String getNazione() {
        return nazione;
    }

    public void setNazione(String nazione) {
        this.nazione = nazione;
    }

    @XmlTransient
    public Collection<Escursione> getEscursioneCollection() {
        return escursioneCollection;
    }

    public void setEscursioneCollection(Collection<Escursione> escursioneCollection) {
        this.escursioneCollection = escursioneCollection;
    }

    @XmlTransient
    public Collection<Volo> getVoloCollection() {
        return voloCollection;
    }

    public void setVoloCollection(Collection<Volo> voloCollection) {
        this.voloCollection = voloCollection;
    }

    @XmlTransient
    public Collection<Volo> getVoloCollection1() {
        return voloCollection1;
    }

    public void setVoloCollection1(Collection<Volo> voloCollection1) {
        this.voloCollection1 = voloCollection1;
    }

    @XmlTransient
    public Collection<Hotel> getHotelCollection() {
        return hotelCollection;
    }

    public void setHotelCollection(Collection<Hotel> hotelCollection) {
        this.hotelCollection = hotelCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (cap != null ? cap.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Citta)) {
            return false;
        }
        Citta other = (Citta) object;
        if ((this.cap == null && other.cap != null) || (this.cap != null && !this.cap.equals(other.cap))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.Citta[ cap=" + cap + " ]";
    }
    
}
